ERPNext Naming Series - Batch & Serial Numbers

Naming of batch and serial numbers within ERPNext is a bit of a mystery. Here's what you can do!

 · 2 min read

Within manufacturing and distribution it is common to need to trace individual items with a serial number, or a quantity of a product with a batch number, or both.


ERPNext of course handles all of the above, allowing you to trace all your material in any stock movements, but the numbering functionality isn't entirely clear at first glance. the information below is accurate as of ERPNext version 15.


Batch Numbers

In Stock Settings -> Serial & Batch Item -> Have Default Naming Series for Batch ID? -> Naming Series Prefix there is a global default Batch number format. If this is not set, BATCH-.##### will be used as a hard-coded default.


To use that, an Item needs to have batch numbers as a requirement enabled. This is in Item -> Inventory -> Serial Nos and Batches -> Has Batch No


  1. If Automatically Create New Batch is not checked, a transaction cannot be submitted until you enter a batch number manually, in the transaction item child table;
  2. If checked you can specify a Batch Number Series which will override the global default format from above.


The format for each of these batch number formats is the same as Naming Series and Serial numbers and is given below. You can view all of your Batches in the Batch List.


Serial Numbers

There is no global default format for serial numbers, since it is assumed each item will probably have its own format.


However, if you do need a global default, you could customise the Item doctype with your favourite serial number format as a default. If you use the same format on multiple Items, the system will keep them sequential.


Item -> Inventory -> Serial Nos and Batches -> Has Serial No enables the serial number feature for an Item

  1. If you specify the Serial Number Series, one will be created for you automatically on a transaction if none are specified;
  2. If you leave the field blank, a transaction will fail submission with a message: Serial Nos Required for Serialized Item


Serial numbers use the same format as below and can be viewed in the Serial No List.


Naming Series Format

In Document Naming Settings -> Setup Series for transactions, if you select a doctype it shows this useful information:



This format can be used not just for Series and Batch numbers, but any doctype set to use a naming series. The {fieldname} option however is not available for Serial and Batch numbers.


If you haven't found the customisation features for each doctype, go to the top right-hand ellipsis menu button, and select Customize.



Here you can modify the default document naming behaviour in the Naming section:



Undocumented Batch Feature


If you've made it this far, here's a secret feature as a reward:


Batch number formats are first rendered as a Jinja template using the draft Batch document as context, which makes this format possible:

BATCH-{{ item }}-{{ expiry_date }}.#


This might be useful for Items set with an expiry date, like food. Oddly, Serial numbers do not have this functionality!


No comments yet.

Add a comment
Ctrl+Enter to add comment